﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ICarPool.ORM.Attributes;

namespace ICarPool.ORM.EntityManager
{
    public interface IEntityManager
    {
        IDbTransaction Transaction{get;set;}

        int Save<T>(T entity) ;

        int Update<T>(T entity) ;

        int Remove<T>(T entity) ;

        int Remove<T>(object id) where T :new() ;

        int RemoveByCondition<T>(string condition) where T : new();

        T FindById<T>(object id) where T : new();

        List<T> FindAll<T>() where T : new();

        List<T> FindAll<T>(int pageIndex, int pageSize, out int totalCount,string orderBy) where T :  new();

        List<T> FindBySql<T>(string strSql) where T :  new();

        List<T> FindBySql<T>(string strSql, int pageIndex, int pageSize, out int totalCount, string orderBy) where T : new();

        /// <summary>
        /// 对象属性所对应的列进行查询
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="strSql">要查询的条件。eg: Name=peter,Name是表中的列名</param>
        /// <returns>要查询的对象集合</returns>
        List<T> FindByCondition<T>(string condition) where T : new();

        /// <summary>
        /// 对象属性所对应的列进行查询
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="strSql">要查询的条件。eg: Name=peter,Name是表中的列名</param>
        /// <returns>要查询的对象集合</returns>
        List<T> FindByCondition<T>(string condition, int pageIndex, int pageSize, out int totalCount, string orderBy) where T : new();
    }
}
